#ifndef __EEDIT_MEM_S__
#define __EEDIT_MEM_S__

#include "syntax.h"

#define STANDARD_LINE 0x01
#define FOLD_START 0x02
#define FOLDED 0x04
#define FOLD_END 0x08

typedef int CHARACTER;
#define SIZE_OF_CHARACTER sizeof(CHARACTER)

typedef long POSITION;
#define SIZE_OF_POSITION sizeof(POSITION)

#define CHUNK_SIZE 50
#define MSG_LEN 200

/*
 * Storage within eedit is simple, flexible and in no 
 * way optimised for anything ;-)
 * Storage works at the top level of per-file. 
 * Each file is represented by a buffer_t each buffer_t is a collection 
 * of chunks (chunk_t) and also holds some other information.
 */

/*
 * A chunk can be simply a list of characters _or_ a fold.
 * A fold has a seperate internal list of folded lines
 */
typedef struct chunk_tag
{
    int type;
    int length; /* Number of used characters (inc '\n') */
    int length_sans_newline; /* length -- SUM('\n') */
    int local_pos; /* A general reference point. Can be used for anything*/

    char* mem;
    /* double linked list for storage */
    struct chunk_tag* prev;
    struct chunk_tag* next;

    struct chunk_tag* fold;
    int folded_chunks;

    /* single linked list for sub-chunks */
    struct chunk_tag* sub_next;

    syntax_token_t* syn;    /* Syntax.h */
}
chunk_t;

typedef struct
{
    int num_chunks;
    chunk_t* head;
    chunk_t* tail;
    /* These allow changes to be made in context */
    chunk_t* context; /* The last chunk to recieve attention */
    int prev_position;
}
buffer_t;

#endif
